print("*"*10,"SQLite操作","*"*10)
import sqlite3
cozz=sqlite3.connect('zoomla.db')
cursor=cozz.cursor()    #创建一个caozuo

#cursor.execute("create table user(id int(10) primary key,name varchar(20))") #创建user表
#cursor.close()
#cozz.close()

# 写入数据
#cursor.execute("insert into user(id,name) values('1','mrsoft')")
#cursor.execute("insert into user(id,name) values('2','zoomla')")
#cursor.execute("insert into user(id,name) values('3','fage')")
#cursor.execute("insert into user(id,name) values('4','73ic')")
#cursor.close() #关闭游标
#cozz.commit() #提交事务
#cozz.close() #关闭connection

cursor.execute("select * from user")
r结果=cursor.fetchone()   #获取查询结果
print(r结果)
#cursor.close() #关闭游标
#cozz.close() #关闭connection

cursor.execute("select * from user")
r结果=cursor.fetchmany(3)   #获取查询结果获得列表
print(r结果)

cursor.execute("select * from user")
r结果=cursor.fetchall()   #获取查询结果获得列表
print(r结果)


print("*"*10,"pymssql操作","*"*10)

import pymssql
server="127.0.0.1"
user="sa"
passwrod="www.z01.com"

conn=pymssql.connect(server,user,passwrod,database="Zoomla2020")
cursor=conn.cursor()
cursor.execute("select userid,username,* from zl_user")
r=cursor.fetchall()
print(r)

for x in r:
    print("ID:{userid},姓名：{username}".format(userid=x[0],username=x[1]))